home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / c / uw_1.exe / UW.H < prev    next >
Text File  |  1992-11-03  |  17KB  |  441 lines

  1. /****************************************************************************/
  2. /*                                                                                                                                                    */
  3. /* UW.H                                                                                                                                            */
  4. /*                                                                                                                                                    */
  5. /* This is the main header for uWin, containing all the defines and                    */
  6. /* typedefs for the program.                                                                                                */
  7. /*                                                                                                                    Kevin Huck            */
  8. /*                                                                                                                    Boyd Gafford        */
  9. /*                                                                                                                                                    */
  10. /****************************************************************************/
  11. #ifndef __UW_H
  12. #define __UW_H
  13.  
  14. #include <dos.h>                            /* for the REGS definition used for mouse int    */
  15. #include <stdlib.h>
  16. #include <time.h>
  17. #include <conio.h>
  18. #include <string.h>
  19. #include <ctype.h>
  20.  
  21. #ifndef __ZTC__
  22. #ifdef M_I86                                /* Microsofts are malloc.h and memory.h        */
  23.     #include <malloc.h>
  24.     #include <memory.h>
  25.     #include <sys\types.h>
  26.     #pragma pack(1)
  27. #else                                                /* Borlands are alloc.h and mem.h              */
  28.     #include <alloc.h>
  29.     #include <mem.h>
  30. #endif
  31. #endif
  32.  
  33. #ifdef M_I86
  34. #include <stddef.h>
  35. #define setmem(p,c,v)                memset((p),(v),(c))
  36. #define movmem(s,d,c)                memmove((d),(s),(c))
  37. #define random(x)               (rand() % (x))
  38. #define bioskey(c)                    _bios_keybrd(c)
  39. #define biosprint(s, d, p)    _bios_printer(s, p, d)
  40. #define getvect(i)          _dos_getvect(i)
  41. #define setvect(i,hdlr)     _dos_setvect(i,hdlr)
  42. #define enable              _enable
  43. #define disable             _disable
  44. #define setcolor            _setcolor
  45. #define moveto              _moveto
  46. #define lineto              _lineto
  47. #define outbyte outp
  48. #define inbyte  inp
  49. #define outword outpw
  50. #define inword  inpw
  51. struct  REGPACK {
  52.     unsigned    r_ax, r_bx, r_cx, r_dx;
  53.     unsigned    r_bp, r_si, r_di, r_ds, r_es, r_flags;
  54. };
  55. enum COLORS {
  56.     BLACK, BLUE, GREEN, CYAN, RED, MAGENTA, BROWN,
  57.     LIGHTGRAY, DARKGRAY, LIGHTBLUE, LIGHTGREEN,
  58.     LIGHTCYAN, LIGHTRED, LIGHTMAGENTA, YELLOW, WHITE
  59. };
  60. #define C80  3
  61. #define BW80 2
  62. #define MONO 7
  63. #else
  64. #define outbyte outportb
  65. #define inbyte  inportb
  66. #define outword outport
  67. #define inword  inport
  68. #endif
  69.  
  70. #ifdef __POWERC
  71.     #define C80     3
  72.     #define BW80  2
  73.     #define MONO    7
  74. enum COLORS {
  75.     BLACK, BLUE, GREEN, CYAN, RED, MAGENTA, BROWN,
  76.     LIGHTGRAY, DARKGRAY, LIGHTBLUE, LIGHTGREEN,
  77.     LIGHTCYAN, LIGHTRED, LIGHTMAGENTA, YELLOW, WHITE
  78. };
  79. #endif
  80.  
  81. #ifdef __ZTC__
  82. #include <int.h>
  83. #define interrupt
  84. #define O_TRUNC 0
  85. #define O_BINARY 0
  86. #define enable  int_on
  87. #define disable int_off
  88. #endif
  89.  
  90. /*-------------------------------- debug defines ---------------------------*/
  91. #ifdef ENQ_DEBUG 
  92. #define DBG_POP()  dbg_pop()
  93. #define ENQ_ERROR( p1, p2, s1, s2, p ) enq_error( p1, p2, s1, s2, p )
  94. #define WNP_VLD( s, m, wnp )           wnp_vld( s, m, wnp )
  95. #define PRTP_VLD( s, m, prtp )         prtp_vld( s, m, prtp )
  96. #define P_VLD( s, gp )                 p_vld( s, gp )
  97. #define MENUP_VLD( s, m, menup )       menup_vld( s, m, menup )
  98. #define DBG_LOG( fname )               dbg__log( fname )
  99. #else
  100. #define DBG_POP()
  101. #define ENQ_ERROR( p1, p2, s1, s2, p )
  102. #define WNP_VLD( s, m, wnp )
  103. #define PRTP_VLD( s, m, prtp )
  104. #define P_VLD( s, gp )
  105. #define MENUP_VLD( s, m, menup )
  106. #define DBG_LOG( fname )
  107. #endif
  108.  
  109.  
  110. /*------------------------ rectangle operation defines ---------------------*/
  111. #define     NO_OVERLAP            0
  112. #define        OVERLAP                    1
  113. #define        FIRST_ENCLOSED    2
  114. #define        SECOND_ENCLOSED    3
  115.  
  116. /*---------------------------- general defines -----------------------------*/
  117. #define   ON        1
  118. #define   OFF       0
  119. #define   UP        0
  120. #define   DOWN      1
  121. #define   LEFT      2
  122. #define   RIGHT     3
  123.  
  124. /*------------------------------ menuing defines ---------------------------*/
  125. #define     M_HORIZONTAL            0
  126. #define     M_VERTICAL                1
  127. #define     M_MAX_ENTRIES            20
  128. #define        M_GET_EVENT                0
  129. #define        M_PROC_EVENT            1
  130. #define        M_EXIT_ON_ESC         1
  131.  
  132.  
  133. /*---------------------------- mouse defines -------------------------------*/
  134. #define        TDELAY (clock_t) 4    /* clock ticks to check for multiple clicks        */
  135. #define        LB                0                    /* m_event->flag is 4 for left button                 */
  136. #define        MB                2                    /* m_event->flag is 64 for middle button            */
  137. #define        RB                1                    /* m_event->flag is 16 for right button                */
  138.  
  139. /*---------------------------- window defines ------------------------------*/
  140. #define   NO_BDR    0
  141. #define   SGL_BDR   1
  142. #define   DBL_BDR   2
  143. #define   SLD_BDR   3
  144. #define        DUAL_BDR    4
  145.  
  146. #define   CENTERED   -1
  147. #define   LEFT_JUST  -2
  148. #define   RIGHT_JUST -3
  149.  
  150. #define     ALPHA           'A'
  151. #define     DIGITS       'D'
  152. #define     C_LINE            0
  153. #define     C_SBLOCK    1
  154. #define     C_FBLOCK    2
  155.  
  156. #define   IN             0
  157. #define   OUT              1
  158. #define   BUFF             0
  159. #define   SAVE            1
  160.  
  161. #define        WN_POPUP    1
  162. #define        WN_NORMAL    0
  163.  
  164. #define   DELETE    1
  165. #define   INSERT    0
  166.  
  167. #define   STRIP_ON  1
  168. #define   STRIP_OFF 0
  169.  
  170. /*----------------------- printer support defines --------------------------*/
  171. #define PRT_BLOCK 2048
  172. #define MAX_PRINTERS 4
  173.  
  174. #define BLOCK_SIZE 512
  175.  
  176. #define READ  0
  177. #define WRITE 1
  178.  
  179. /*------------------------- flags for wn_gets_ll ---------------------------*/
  180. #define G_STRIP          0x0001
  181. #define G_STRIP_END      0x0002
  182. #define G_UP_FST_CHAR    0x0004
  183. #define G_ARROW          0x0008
  184. #define G_VALIDATE       0x0010
  185. #define G_RIGHT_TO_LEFT  0x0020
  186. #define G_EXIT_ON_FILL   0x0040
  187. #define G_CLEAR_ON_FIRST 0x0080
  188. #define G_UP_FST_CHAR2   0x0100
  189. #define G_MOVE_TO_END    0x0200
  190. #define G_INSERT         0x0400
  191.  
  192.  
  193. #define H_ENTRY          0
  194. #define H_PROCESS        1
  195. #define H_EXIT           2
  196.  
  197. /*-------------------------- base level typedefs ---------------------------*/
  198. typedef unsigned char uchar;
  199. typedef unsigned int  uint;
  200. typedef unsigned long ulong;
  201.  
  202. /*---------------------------- mouse structures ----------------------------*/
  203. typedef struct reset_struct
  204. {
  205.     int exists;
  206.     int n_buttons;
  207. } M_RESET;
  208.  
  209. typedef struct loc_struct
  210. {
  211.     int button_status;
  212.     int count;
  213.     int col;
  214.     int row;
  215. } M_LOC;
  216.  
  217. typedef struct move_struct
  218. {
  219.     int h_count;
  220.     int v_count;
  221. } M_MOVE;
  222.  
  223. typedef struct event_struct
  224. {
  225.     int          is_mouse;
  226.     int            key;
  227.     int            mod;
  228.     int            m_x, m_y;
  229.     int          m_count, m_button;
  230. } EVENT;
  231.  
  232. /*---------------------------- rectangle structure -------------------------*/
  233. typedef struct rect_struct
  234. {
  235.     int x_min, x_max, y_min, y_max;                    /* rectangle coordinates                     */
  236. } RECT;
  237.  
  238.  
  239. /*--------------------------- window structure -----------------------------*/
  240. typedef struct w_struct
  241. {
  242.     struct w_struct    *next;                                    /* next window in linked list            */
  243.     struct w_struct    *previous;                            /* previous window in list                */
  244.     RECT                        pane;                   /* the window rectangle           */
  245.     RECT                        old_pane;               /* for full size toggle           */
  246.     int                            rows;                                        /* save buffer rows and columns        */
  247.     int                            cols;
  248.     int                         csr_x;                  /* the "soft" cursor location     */
  249.     int                         csr_y;
  250.     uchar                        att;                    /* the window's attribute         */
  251.     uchar                        bdr_att;                /* the window's border attribute  */
  252.     int                         bdr_style;              /* the border style               */
  253.     int                         name_loc;                                /* CENTERED, LEFTJUST, RIGHTJUST    */
  254.     char                        *name;                  /* pointer to window name         */
  255.     uchar                        *save;                                    /* pointer to save buffer area        */
  256.     uchar                        *buff;                                    /* pointer to write buffer area        */
  257.     uchar                        *mask;                                    /* pointer to window buffer mask    */
  258.  
  259.     uchar           *tabs;                                    /* tab stops                      */
  260.     int                            reg_s, reg_e;                        /* scroll region start and end        */
  261.  
  262.     unsigned                hidden            : 1;        /* 1 if window hidden             */
  263.     unsigned                overlapped    : 1;        /* 1 if window overlapped         */
  264.     unsigned                csr_adv            : 1;                /* 1 if cursor auto advanced      */
  265.     unsigned                 inside      : 1;                /* 1 if bordered and inside              */
  266.     unsigned                 mask_on     : 1;                /* 1 if window mask is active            */
  267.     unsigned                popup                :    1;                /* 1 if window is popup                        */
  268.     unsigned                 scroll      : 1;                /* 1 if window auto-